00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00052 define("PATH_TO_ROOT", "../");
00054 require_once (PATH_TO_ROOT."common/init.inc.php");
00055
00056 require_once (PATH_TO_ROOT."forum/classes/distribution/class.distributor.inc.php");
00057 require_once (PATH_TO_ROOT."forum/classes/distribution/class.subscribersdistributionhandler.inc.php");
00058 require_once (PATH_TO_ROOT."forum/classes/distribution/class.mustseedistributionhandler.inc.php");
00059
00061 require_once (PATH_TO_ROOT."common/classes/class.email.inc.php");
00062 require_once (PATH_TO_ROOT."common/classes/class.modifypic.inc.php");
00064 require_once (PATH_TO_ROOT."photogallery/admin/classes/class.gallerysettings.inc.php");
00066 require_once (PATH_TO_ROOT."common/tinymceconfig.inc.php");
00067 $gSettings = new GallerySettings();
00068 if (isset($_POST['Cancel'])) {
00069 header("Location: ".$_SERVER['PHP_SELF']);
00070 exit;
00071 }
00073 require_once (PATH_TO_ROOT."common/header.inc.php");
00074 require_once "header.inc.php";
00075 writeContentHeader(Output::getIcon("icon_photogallery", "FotoForum") ."FotoForum");
00076 require_once "./classes/class.header.inc.php";
00077
00078 $post['posttext'] = ((isset($_POST['post'])) ? $_POST['post']['posttext'] : '');
00079 if ($g_user['userID'] == 0 && !$P->has_permission(P_POSTNEW)) message("Hinweis", "Sie müssen registriert sein, um Bilder uploaden zu können");
00080
00081 if (!isset($board['boardid']) || !getAlbumRight('upload', $board['boardid']) || ($_SESSION["usergroup"] > ADMIN && isset($_SESSION["invisible"])) || $board['boarddisabled']) {
00082 $forbidden = true;
00083 if (isset($board['boardid']) && $board['boarddisabled']) {
00084 $prights = getAlbumRights($board['boardid']);
00085 $forbidden = !testPhotoRight($prights, 'admin');
00086 }
00087 if ($forbidden) {
00088 echo "<div class='error'>Sie haben nicht das Recht, Bilder in dieses Album zu laden!</div>";
00089 include_once "footer.inc.php";
00091 require_once (PATH_TO_ROOT."common/footer.inc.php");
00092 exit;
00093 }
00094 }
00095 if (isset($_SESSION["roleID"])) {
00096 $role = new Role($_SESSION["roleID"]);
00097 $roleInfoText = "<tr><td colspan='2' class='message'>Sie nehmen zur Zeit die Rolle <strong>".Data::toHTML($role->getName($_SESSION["gender"]), false) ."</strong> ein.<br />Wenn Sie einen Beitrag im Forum verfassen, wird dieser unter Ihrem Rollennamen und mit Ihrem Rollenavatar veröffentlicht.</td></tr>";
00098 } else {
00099 $role = null;
00100 $roleInfoText = "";
00101 }
00102 if (isset($_SESSION["teamID"])) {
00103 $team = new Team($_SESSION["teamID"]);
00104 } else $team = null;
00105 if ($gSettings->get_maximages()) {
00106 if ($gSettings->get_maximages() <= $db->get_var("SELECT COUNT(*) FROM forum_thread WHERE boardid=".$board['boardid'])) {
00107 echo "<div class='error'>Das Limit an ".$gSettings->get_maximages() ." Bildern für dieses Album ist bereits erreicht!</div>";
00108 include_once "footer.inc.php";
00110 require_once (PATH_TO_ROOT."common/footer.inc.php");
00111 exit;
00112 }
00113 }
00114 $newtopicicons = '';
00115 $j = 1;
00116 while (list($iconid, $img) = each($topicicon)) {
00117 $newtopicicons.= "<p class='pForm'><input type=\"radio\" name=\"thread[threadiconid]\" value=\"$iconid\" ".(isset($_POST["thread"]["threadiconid"]) && $_POST["thread"]["threadiconid"] == $iconid ? "checked='checked' " : "") ."/></p>
00118 <img src=\"".PATH_TO_ROOT."forum/templates/images/icon/".$img."_new.png\" alt='Topic Icon' /> ";
00119 if ($j%6 == 0) {
00120 $newtopicicons.= "<br/>";
00121 }
00122 $j++;
00123 }
00124
00125 $ranking_value=0;
00126
00127
00128
00129
00130 if (isset($_POST['evaluation'])) {
00131 $eval_checked = ' checked="checked"';
00132 $ranking_value = $_POST['evaluation'];
00133 } else {
00134 $eval_checked = '';
00135 }
00136
00137 $picOK = isset($_POST['picOK']);
00138 $maxFileSize = $gSettings->get_maxfilesize() /1024;
00139 if ($maxFileSize > 1024) {
00140 $showMaxFileSize = round($maxFileSize/1024, 2) ." MB";
00141 } else $showMaxFileSize = $maxFileSize." KB";
00142 if (isset($_GET['boardid'])) $bid = $_GET['boardid'];
00143 else $bid = $board['boardid'];
00144 $msg = "";
00145
00146
00147
00148
00149 if (isset($_FILES['picfile']['size'])) {
00150 $filesize = $_FILES['picfile']['size'];
00151 if (($filesize > $gSettings->get_maxfilesize()) || ($_FILES['picfile']['error'] == UPLOAD_ERR_FORM_SIZE) ) $msg.= "Die Datei ist zu groß!<br/>";
00152 if (!(upload::fileExtOK($_FILES['picfile']['name']))) $msg.= "Die Datei hat ein unerlaubtes Dateiformat.";
00153 if (!$msg) {
00154 $post['postfilename'] = $_FILES['picfile']['name'];
00155 $ext = strrchr($post['postfilename'], '.');
00156 $uploaddir = PATH_TO_ROOT.$settings["upload_path"]."photogallery_temp";
00157 Utilities::mkdir_r($uploaddir);
00158
00159 $uploadFileName = $uploaddir."/".$post['postfilename'];
00160 if (!(@move_uploaded_file($_FILES['picfile']['tmp_name'], $uploadFileName))) $msg = "Fehler beim Speichern der Datei!";
00161 else {
00162 if (in_array(strtolower($ext), array('.jpg', '.jpe', '.jpeg'))) {
00163 ModifyPic::pureJPEG($uploadFileName);
00164 }
00165 message_redirect("Bild wurde erfolgreich hochgeladen. Bearbeitungstool wird geladen!", "modifypic.php?picurl=$uploadFileName&ext=$ext&mode=newpic&boardid=$bid");
00166 }
00167 }
00168 }
00169 if (isset($_GET['picOK']) && $_GET['picurl']) {
00170 $post['newpicfileupload'] = '
00171 <tr class="tableCellDark" valign="top">
00172 <td>Bilddatei</td>
00173 <td>
00174 <img src="'.PATH_TO_ROOT.'common/makethumb.php?picurl='.rawurlencode(Data::toHTML($_GET['picurl'])) .'&maxh=300&maxw=400" alt="Bildansicht" align="left" style="margin-right: 10px; border: 1px solid #000000;" />
00175 <input type="hidden" name="post[postfilenameOK]" value="'.Data::toHTML($_GET['picurl']) .'" />
00176 <input type="hidden" name="picOK" value="1" />
00177 </td>
00178 </tr>';
00179 } else {
00180 $msg_error = '';
00181 if ($msg) $msg_error = '<br /> <span style="color: #dd0000;">'.$msg.'</span>';
00182 $post['newpicfileupload'] = '
00183 <tr class="tableCellDark" valign="top">
00184 <td>Bilddatei</td>
00185 <td>
00186 <p class="pForm">
00187 <input type="hidden" name="MAX_FILE_SIZE" value="'.($gSettings->get_maxfilesize()) .'" />
00188 <input class="tbinput" type="file" name="picfile" size="30" /> maximal '.$showMaxFileSize.'
00189 </p>
00190 '.$msg_error.'
00191 </td>
00192 </tr>';
00193 }
00194 if (!$picOK) {
00195 $codechecked = "checked='checked'";
00196 if ($config['smilies']) {
00197 $smilies_on_off = "AN";
00198 $smilietext = "<tr class='tableCell'> <td>Smilies</td> <td> <p class='pForm'><input type='checkbox' id='smilies' name='post[postsmilies]' value='1' checked='checked' /></p>
00199 <label for='smilies'>Smilies wie :), ;) usw. als Grafiken darstellen?</label></td></tr>";
00200 } else {
00201 $smilies_on_off = "AUS";
00202 $smilietext = "";
00203 }
00204 if ($config['use_email']) $notifyavailable = '';
00205 else $notifyavailable = ' (Derzeit nicht verfügbar)';
00206 $replytext = '';
00207 $title = '<p class="pForm"><input class="tbinput" tabindex="1" type="text" name="thread[threadtopic]" size="50" maxlength="'.$config['subject_maxlength'].'" value="'.(isset($thread['threadtopic']) ? Data::toHTML($thread['threadtopic'], false) : '') .'"/></p>';
00208 if ($g_user['userID']) {
00209 $replyusername = $g_user['userhtmlname'];
00210 if (isset($role)) {
00211 $replyusername.= " (".Data::toHTML($role->getName($_SESSION["gender"]), false) .")";
00212 $replytext = "\n\n\n".Data::toHTML($role->getSetting("forum_sig", true));
00213 }
00214 if (isset($team)) {
00215 $replyusername.= " (".$team->getName() .")";
00216 }
00217 } else {
00218 if ($g_user['userID'] == 0 && $P->has_permission(P_POSTNEW)) $replyusername = '<p class="pForm"><input class="tbinput" name="post[postguestname]" type="text"/></p>';
00219 else $replyusername = '';
00220 }
00221 $Tframe = new Template("templates/frame.html");
00222
00223 if (isset($_GET['picOK']) && $_GET['picurl']) $Tform = new Template("templates/newtopic_2nd.html");
00224 else $Tform = new Template("templates/newtopic_1st.html");
00225 $navpath.= 'Neues Bild uploaden';
00226 eval($Tform->GetTemplate("CONTENT"));
00227 eval($Tframe->GetTemplate());
00228 } else {
00229 $board_id = $board['boardid'];
00230
00231 if (isset($post['preview'])) {
00232 $bbcode = new BBCode(true, $config["imageslevel"] != 2, (bool)$post["postsmilies"], (bool)$post["postcode"], true);
00233 $post['pretext'] = $bbcode->parse($post['posttext']);
00234 if (isset($g_user['userhidesig']) && $g_user['userhidesig'] != 1 && !empty($g_user['usersignature']) && !isset($role)) $post['pretext'].= "<br/>-- <br/>".$mainBBCode->parse($g_user['usersignature']);
00235 $replytext = Data::toHTML($post['posttext'], false);
00236 $Tpostings = new Template("templates/newtopic_2nd.html");
00237 $Tframe = new Template("templates/frame.html");
00238 $Tpostingrow = new Template("templates/preview_firstrow.html");
00239 $topicicon[0] = 'fullalpha';
00240 if ($g_user['userID']) {
00241 $replyusername = "$g_user[userhtmlname]";
00242 $post['avatar'] = '';
00243 if (isset($role)) {
00244 $replyusername.= " (".Data::toHTML($role->getName($_SESSION["gender"]), false) .")";
00245 $avatarURL = $role->getAvatarURL($g_user["userID"]);
00246 if (!empty($avatarURL)) {
00247 $post["avatar"] = "<img src='$avatarURL' alt='Avatar von $replyusername' />";
00248 }
00249 }
00250 if (isset($team)) {
00251 $replyusername.= " (".$team->getName() .")";
00252 }
00253 } else {
00254 if ($config['guestmode']) $replyusername = "$post[postguestname]<p class='pForm'><input type=\"hidden\" name=\"post[postguestname]\" value=\"$post[postguestname]\"/></p>";
00255 else $replyusername = '';
00256 }
00257 if ($post['postcode']) $codechecked = ' checked="checked"';
00258 else $codechecked = '';
00259 if ($post['postsmilies']) $smilieschecked = ' checked="checked"';
00260 else $smilieschecked = '';
00261 if ($config['smilies']) {
00262 $smilies_on_off = "AN";
00263 $smilietext = "<tr class='tableCell'> <td>Smilies</td> <td> <p class='pForm'><input type='checkbox' id='smilies' name='post[postsmilies]' value='1' $smilieschecked /></p>
00264 <label for='smilies'>Smilies wie :), ;) usw. als Grafiken darstellen?</label></td></tr>";
00265 } else {
00266 $smilies_on_off = "AUS";
00267 $smiliestext = "";
00268 }
00269 if ($config['use_email']) $notifyavailable = '';
00270 else $notifyavailable = ' (Derzeit nicht verfügbar)';
00271 $post['newpicfileupload'] = '
00272 <tr class="tableCellDark" valign="top">
00273 <td>Bilddatei</td>
00274 <td>
00275 <img src="'.PATH_TO_ROOT.'common/makethumb.php?picurl='.rawurlencode($post['postfilenameOK']) .'&maxh=300&maxw=400" alt="Bildansicht" style="border: 1px solid #000000;" />
00276 <input type="hidden" name="post[postfilenameOK]" value="'.$post['postfilenameOK'].'" />
00277 <input type="hidden" name="picOK" value="1" />
00278 </td>
00279 </tr>';
00280 $post['thumbnail'] = '<img src="'.PATH_TO_ROOT.'common/makethumb.php?picurl='.rawurlencode($post['postfilenameOK']) .'&maxh=300&maxw=400" alt="Bildansicht" style="border: 1px solid #000000;" />';
00281 $pixelSize = getimagesize($post['postfilenameOK']);
00282 $post['picfile'] = substr(strrchr($post['postfilenameOK'], "/"), 1, strlen(strrchr($post['postfilenameOK'], "/")) -1);
00283 $post['picsize'] = $pixelSize[0]."x".$pixelSize[1]." Pixel";
00284 $post['postfilesize'] = round(filesize($post['postfilenameOK']) /1024) ." KByte";
00285 $time = Output::echoDate("d.m.Y, H:i") ." Uhr";
00286 $title = '<p class="pForm"><input class="tbinput" tabindex="1" type="text" name="thread[threadtopic]" size="50" maxlength="'.$config['subject_maxlength'].'" value="'.Data::toHTML($thread['threadtopic'], false) .'"/></p>';
00287 $navpath.= 'Bild Vorschau';
00288 eval($Tpostings->GetTemplate("RFORM"));
00289 eval($Tpostingrow->GetTemplate("CONTENT"));
00290 eval($Tframe->GetTemplate());
00291 include_once "footer.inc.php";
00293 require_once (PATH_TO_ROOT."common/footer.inc.php");
00294 exit;
00295 }
00296
00297 if ($picOK) {
00298 $msg = '';
00299
00300 if ($config["usebwordprot"] == BWORD_TOPIC || $config["usebwordprot"] == BWORD_ALL) $thread["threadtopic"] = check_banned($thread["threadtopic"]);
00301 if ($config["usebwordprot"] >= BWORD_POST) $post["posttext"] = check_banned($post["posttext"]);
00302 if (strlen($thread['threadtopic']) > $config['subject_maxlength']) $msg.= "Der Betreff ist zu lang!<br/>";
00303 if (strlen($thread['threadtopic']) < $config['subject_minlength']) $msg.= "Der Betreff ist zu kurz!<br/>";
00304 $testlen = strlen(preg_replace("/(\s+|( )+)/", '', (isset($post['postcode']) ? $mainBBCode->stripTags($post['posttext']) : $post['posttext'])));
00305 if ($testlen < $config['message_minlength']) $msg.= "Der Text ist zu kurz!<br/>";
00306 if ($testlen > $config['message_maxlength']) $msg.= "Der Text ist zu lang!<br/>";
00307 if (strlen($msg) > 0) {
00308 $navpath.= 'Neues Bild';
00309 errormessage("Fehler", "Es sind leider folgende Fehler aufgetreten:<br/><br/>$msg");
00310 }
00311 if (!$P->has_permission(P_NOFLOODPROT) && time() -$config['postdelay'] < $g_user['userlastpost']) {
00312 $navpath.= 'Neues Bild';
00313 errormessage("Fehler", "Sie können nur alle $config[postdelay] Sekunden einen neuen Thread erstellen.");
00314 }
00315 $time = time();
00316 if (!isset($thread['topiciconid']) || !$topicicon[($thread['topiciconid']) ]) $thread['topiciconid'] = 0;
00317 if ($P->has_permission(P_POSTNEW) && ($g_user['userID'] == 0)) {
00318 $g_user['username'] = $config['guestprefix'].$post['postguestname'];
00319 $post['postguestname'] = $config['guestprefix'].addslashes($post['postguestname']);
00320 } else $post['postguestname'] = '';
00321
00322 if (isset($config['auto_close']) && $config['auto_close'] > 0) forum_query("UPDATE forum_thread SET threadclosed = '1' WHERE threadtime < '".(time() -(($config['auto_close']+1) *86400)) ."'");
00323 if (isset($config['auto_delete']) && $config['auto_delete'] > 0) forum_query("DELETE FROM forum_thread WHERE threadtime < '".(time() -($config['auto_delete']*86400)) ."'");
00324
00325 if ($post['postfilenameOK']) {
00326 $post['postfilename'] = strrchr($post['postfilenameOK'], '/');
00327 $post['postfilename'] = substr($post['postfilename'], 1, (strlen($post['postfilename']) -1));
00328 $post['postfilesavename'] = $_SESSION['userid'].time() .$_SESSION['course'];
00329 $post['postfilesize'] = filesize($post['postfilenameOK']);
00330 $courseID = $_SESSION['course'];
00331 $boardID = $board['boardid'];
00332
00333
00334 $uploaddir = PATH_TO_ROOT.$settings["upload_path"]."forum/course/".$courseID."/board/".$boardID;
00335 Utilities::mkdir_r($uploaddir);
00336
00337 $uploadFileName = $uploaddir."/".$post['postfilesavename'];
00338 if (!(@rename($post['postfilenameOK'], $uploadFileName))) $msg.= "Fehler beim Speichern der Datei!<br/>";
00339 }
00340
00341 $lastReplyBy = $g_user['username'];
00342 if (isset($role)) {
00343 $lastReplyBy.= " (".$role->getName($_SESSION["gender"]) .")";
00344 }
00345 if (isset($team)) {
00346 $lastReplyBy.= " (".$team->getName() .")";
00347 }
00348
00349 forum_query("INSERT INTO forum_thread (threadtime, threadtopic, threadauthor, boardid,
00350 threadlastreplyby, threadiconid, userID, threadcreationtime, threadrate)
00351 VALUES('$time',
00352 '".Data::toMysql($thread['threadtopic'], false) ."',
00353 '".Data::toMysql($lastReplyBy, false) ."',
00354 '".intval($board['boardid']) ."',
00355 '".Data::toMysql($lastReplyBy, false) ."',
00356 '0',
00357 ".intval($_SESSION['userid']) .",
00358 '$time',
00359 '" . Data::toMysql($ranking_value) . "')");
00360
00361
00362
00363 $thread['threadid'] = mysql_insert_id();
00364
00365
00366
00367
00368 forum_query("INSERT INTO forum_post (posttime, posttext, userID, threadid, postsmilies,
00369 postcode, postguestname, postfilename, postfilesavename, postfilesize)
00370 VALUES('$time',
00371 '".Data::toMysql($post['posttext'], false) ."',
00372 '".intval($g_user['userID']) ."',
00373 '".intval($thread['threadid']) ."',
00374 '".(int)isset($post['postsmilies']) ."',
00375 '".(int)isset($post['postcode']) ."',
00376 '".Data::toMysql($post['postguestname'], false) ."',
00377 '".Data::toMysql($post['postfilename'], false) ."',
00378 '".Data::toMysql($post['postfilesavename'], false) ."',
00379 '".intval($post['postfilesize']) ."')");
00380
00381 $lastPostBy = $g_user['username'];
00382 $post["postid"] = mysql_insert_id();
00383 if (isset($role)) {
00384 RoleArtefacts::setRoleForItem(FORUM, $post["postid"], $_SESSION["roleID"]);
00385 $lastPostBy.= " (".$role->getName($_SESSION["gender"]) .")";
00386 }
00387 if (isset($team)) {
00388 TeamArtefacts::setTeamForItem(FORUM, $post["postid"], $_SESSION["teamID"]);
00389 $lastPostBy.= " (".$team->getName() .")";
00390 }
00391
00392 forum_query("UPDATE forum_board SET
00393 boardthreads=boardthreads+1,
00394 boardlastpost='$time',
00395 boardposts=boardposts+1,
00396 boardlastpostby='".Data::toMysql($lastPostBy, false) ."',
00397 boardthreadtopic='".Data::toMysql($thread['threadtopic'], false) ."',
00398 boardthreadid='$thread[threadid]'
00399 WHERE boardid='$board[boardid]' AND is_photogallery=1");
00400
00401 if ($g_user['userID']) forum_query("UPDATE forum_user SET userlastpost=$time, userposts=userposts+1 WHERE userID='$g_user[userID]'");
00402
00403 $arrBoardInfo = mysql_fetch_array(forum_query("SELECT mustsee FROM forum_board as board WHERE boardid = $board[boardid] AND is_photogallery=1"));
00404 if ($arrBoardInfo['mustsee'] == 0)
00405 $objDistributionHandler = new SubscribersDistributionHandler(true, $board, $thread, $g_user, $post, $config, $course_name, $settings, $mainBBCode, $db);
00406 else
00407 $objDistributionHandler = new MustseeDistributionHandler(true, $board, $thread, $g_user, $post, $config, $course_name, $settings, $mainBBCode, $db);
00408 $objDistributor = new Distributor();
00409 $objDistributor->setDistributionHandler($objDistributionHandler);
00410 $objDistributor->distribute();
00411
00412 message_redirect("Eintrag erfolgreich", "showtopic.php?threadid=$thread[threadid]");
00413 }
00414 }
00415 $eStudyPage->appendJavaScriptFile($js);
00416 include_once "footer.inc.php";
00418 require_once (PATH_TO_ROOT."common/footer.inc.php");
00419 ?>